package com.hephesto.infra.security.crypto;

import com.hephesto.infra.security.crypto.engines.CryptographerBehaviorAES;
import com.hephesto.infra.security.crypto.engines.CryptographerBehaviorSHA256;
import com.hephesto.infra.security.crypto.model.CryptographerAlgoritmSupported;

/**
 * @author rrocha
 */
public class CryptographerFactory {

	private static CryptographerFactory instance;

	private CryptographerFactory() {}

	public static CryptographerFactory getInstance() {
		if (instance == null) 
			instance = new CryptographerFactory();
		return instance;
	}

	/**
	 * 
	 */
	public ICryptographer createCryptographer(CryptographerAlgoritmSupported algoritmSupported, String key) {

		ICryptographer criptografador = null;
		switch (algoritmSupported ) {
			case AES: {
				criptografador = new CryptographerBehaviorAES( key );
				break;
			}
			case SHA_256: {
				criptografador = new CryptographerBehaviorSHA256();
				break;
			}
		}
		return criptografador;
	}

	/**
	 * 
	 */
	public ICryptographer createCryptographer(CryptographerAlgoritmSupported algoritmoSupported) {
		return createCryptographer(algoritmoSupported, null);
	}

}